package com.dk.controller;

import com.dk.RES;
import com.dk.service.OrderRecordService;
import com.dk.vo.OrderRecordVo;
import com.jack.weChatSecurity.core.SecurityHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("/api")
@Controller
public class OrderRecordController {

    @Autowired
    OrderRecordService orderRecordService;

    @GetMapping("/orderRecords")
    @ResponseBody
    public RES getOrderRecords(){
        RES res=new RES();
        try{
            String id= SecurityHelper.getWeChatUser().getId();
            List<OrderRecordVo> orderRecords= orderRecordService.getOrderRecordsByUid(id);
            res.setCode(0).setMsg("ok").addData("orderRecords",orderRecords);
        }catch (Exception e){
            res.setCode(1).setMsg("error");
        }finally {
            return res;
        }
    }
}
